<template>
  <div class="login-container">
    <div class="login-main">
      <div class="left-container"></div>
      <div class="right-container">
        <div class="project-name">
          阎良科研实验及产业基地多能互补系统
          <span class="version">V1.0</span>
        </div>
        <div class="project-name-en">改善系统性能、提高安全经济供能水平</div>
        <el-form ref="form" :model="form" style="margin-top: 50px">
          <el-form-item>
            <el-input v-model="form.userName">
              <i slot="prefix" class="iconfont iconzhanghao" style="margin-left: 10px"></i>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-input v-model="form.passWord" type="password">
              <i slot="prefix" class="iconfont iconmima" style="margin-left: 10px"></i>
            </el-input>
          </el-form-item>
          <el-form-item style="margin-top: 100px">
            <el-button type="primary" style="width: 100%" @click="loginClick">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { cache } from '@utils'

export default {
  data() {
    return {
      form: {
        userName: "admin",
        passWord: "123456"
      }
    };
  },
  methods: {
    async loginClick () {
      console.log(this.form)
      const result = await this.$fetchPost('/user/sysLogin', this.form)
      if (result.code === 200) {
        cache.set('userInfo', result.result)
        this.$message.success('欢迎回来')
        this.$router.push('/')
      } else {
        this.$message.error(result.error);
        
      }
    }
  }
};
</script>

<style lang="less">
.login {
  &-container {
    height: 100vh;
    background: -webkit-linear-gradient(
      left top,
      #5eb5e0,
      #7766f3
    ); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(
      bottom right,
      #5eb5e0,
      #7766f3
    ); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(
      bottom right,
      #5eb5e0,
      #7766f3
    ); /* Firefox 3.6 - 15 */
    background: linear-gradient(
      to bottom right,
      #5eb5e0,
      #7766f3
    ); /* 标准的语法（必须放在最后） */
  }
  &-main {
    width: 1000px;
    height: 500px;
    background: #f9fafc;
    position: fixed;
    left: calc(50% - 500px);
    top: calc(50% - 250px);
    display: flex;
    .left-container {
      flex: 1.2;
      background: url("~static/images/login1.jpg");
      background-size: 100% 100%;
    }
    .right-container {
      flex: 1;
      padding: 50px 40px;
      .project-name {
        font-size: 22px;
        color: #33b2ee;
        font-weight: bold;
        font-family: "arial";
        .version {
          font-size: 15px;
          color: #afb0b2;
        }
      }
      .project-name-en {
        margin-top: 10px;
        font-weight: bold;
        font-size: 20px;
        color: #e0e1e3;
      }
      .el-input__inner {
        padding-left: 40px;
      }
    }
  }
}
</style>